<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title>Focus Issue Child</title>
	<script>
	// open the parent, if user tries to open the child directly
	if (parent == window)
		location.href = './focus-framedojo.html';
	</script>
	<script type="text/javascript" src="../../dojo/dojo.js"
		data-dojo-config="isDebug:true"></script>
	<script type="text/javascript">
		dojo.require("dijit.focus");
		dojo.require("doh.runner");

		// set objects in parent
		for (var v in {'dijit':true, 'dojo':true, 'dojox':true})
			parent[v] = window[v];

		// This will execute before the dojo.ready() code in dijit.focus() executes
		dojo.setContext(parent, parent.document);

		dojo.ready(function(){
			doh.register("focus", function focus(){
				var d = new doh.Deferred();
				doh.is("input", dojo.byId("input").id, "found input");

				dijit.focus.watch("curNode", function(attr, oldVal, newVal){
					console.log("focused on ", newVal);
					if(!newVal){
						return;	// IE gives spurious event
					}
					d.getTestCallback(function(){
						doh.is("input", newVal.id, "notified that focused on input");
					})();
				});

				dojo.byId("input").focus();

				return d;
			});

			doh.run();
		});
	</script>
</head>
<body bgcolor="#e0e0e0">
	this frame is for loading script only
</body>
</html>
